package Day28.Demo;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class Demo01 {
    public static void main(String[] args) throws Exception {
        Class c = Class.forName("Day28.Demo.Book");
        /*Annotation[] as = c.getAnnotations();
        for (Annotation a:as) {
            System.out.println(a);//@Day28.Demo.TableAnnotation(value="Test_Book")
        }*/

        TableAnnotation ta = (TableAnnotation) c.getAnnotation(TableAnnotation.class);//表格
        String value = ta.value();
        System.out.println(value);//Test_Book

        Field[] fs = c.getDeclaredFields();//属性
        for (Field f:fs) {
            ColumnAnnotation ca = f.getAnnotation(ColumnAnnotation.class);
            System.out.println(f.getName() + "属性，对应数据库中的字段:" + ca.columnName() + ",数据类型：" + ca.type() + ",长度:" + ca.length());
        }
    }
}
